<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

Class Sdp_model extends CI_Model {

    private $table = "sdp";

    function __construct() {
        parent::__construct();
    }

    function insert($data = array()) {
        if ($data != '') {
            $val = array(
                'sdp_code' => $data['sdp_code'],
                'remark' => $data['remark'],
                'pon_id' => $data['pon_id']
            );

            $is = ($this->db->insert($this->table, $val) ? $this->db->insert_id() : FALSE);
            return $is;
        }
    }

    function update($data = array()) {
        if ($data != '') {
            $val = array(
                'sdp_code' => $data['sdp_code'],
                'remark' => $data['remark']
            );
            $is = ($this->db->where('sdp_id', $data['sdp_id'])->update($this->table, $val)) ? TRUE : FALSE;
            return $is;
        }
    }

    function delete($data) {
        ($this->db->where('sdp_id', $data)->delete($this->table)) ? $is = TRUE : $is = FALSE;
        return $is;
    }

    function select_by_ponid($pon_id) {
        $rs = $this->db->where('pon_id', $pon_id)->get($this->table)->result();
        return $rs;
    }

    function select_by_filter($id) {
        $rs = $this->db->where('sdp_id', $id)->get($this->table)->row_array();
        return $rs;
    }

}
